package com.chlitina.store.common.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.chlitina.store.common.session.BoTongSessionContext;
import com.chlitina.store.modules.sys.utils.StoreUtils;


@SuppressWarnings("serial")
public class ValidateExit extends HttpServlet  {
	
	public ValidateExit() {
		super();
	}
	
	public void destroy() {
		super.destroy(); 
	}
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		this.doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String sessionId = req.getParameter("sessionId");
		if (sessionId != null && !"".equals(sessionId)) {
			BoTongSessionContext boTongSessionContext = BoTongSessionContext.getInstance();
			HttpSession session = boTongSessionContext.getSession(sessionId);
			if (session != null) {
				session.invalidate();
			}
			StoreUtils.removeBySessionId(sessionId);
		}
	}


}
